//
//  UILabel+Extenssion.m
//  FYAgent
//
//  Created by 曹运 on 15/11/12.
//  Copyright © 2015年 于龙. All rights reserved.
//

#import "UILabel+Extenssion.h"

@implementation UILabel (Extenssion)
- (void)setAttributeTextWithString:(NSString *)textString
                        headIndent:(CGFloat)headIndent
               firstLineHeadIndent:(CGFloat)firstLineHeadIndent
                       lineSpacing:(CGFloat)lineSpacing
                         textColor:(UIColor *)textColor
{
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:textString];
    [text addAttribute:NSForegroundColorAttributeName value:textColor range:NSMakeRange(0, text.length)];
    
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.headIndent = headIndent;
    style.firstLineHeadIndent = firstLineHeadIndent;
    style.lineSpacing = lineSpacing;
    [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
    self.attributedText = text;
    self.lineBreakMode = NSLineBreakByWordWrapping | NSLineBreakByTruncatingTail;
  
}
- (void)setAttributeTextWithString:(NSString *)textString
                         textColor:(UIColor *)textColor
                             range:(NSRange)range
{
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:textString];
    [text addAttribute:NSForegroundColorAttributeName value:textColor range:range];
    self.attributedText = text;
}
- (void)setAttributeTextWithString:(NSString *)textString
                              font:(UIFont *)font
                             range:(NSRange)range
{
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:textString];
    [text addAttribute:NSFontAttributeName value:font range:range];
    self.attributedText = text;
}

@end
